package com.shard.knabejay.birthday;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends AppCompatActivity {
    private Button btn_login;
    private EditText edit_account;
    private EditText edit_password;
    private String account;
    private String password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        btn_login = (Button)findViewById(R.id.btn_login);
        edit_account = (EditText)findViewById(R.id.edit_account);
        edit_password = (EditText)findViewById(R.id.edit_password);

        btn_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                account = edit_account.getText().toString();
                password = edit_password.getText().toString();


                if (account.equals("admin") && password.equals("123")){
                    Intent intent = new Intent(LoginActivity.this, ListActivity.class);
                    startActivity(intent);
                }else{
                    Toast.makeText(getApplication(),"用户名或密码错误", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
